﻿using System;
using System.ComponentModel.DataAnnotations;
using Abp.Authorization.Users;
using Abp.Extensions;

namespace ABCNet.Authorization.Users
{
    public class User : AbpUser<User>
    {
        public const string DefaultPassword = "123qwe";

        public static string CreateRandomPassword()
        {
            return Guid.NewGuid().ToString("N").Truncate(16);
        }

        public static User CreateTenantAdminUser(int tenantId, string emailAddress)
        {
            var user = new User
            {
                TenantId = tenantId,
                UserName = AdminUserName,
                Name = AdminUserName,
                Surname = AdminUserName,
                EmailAddress = emailAddress
            };

            user.SetNormalizedNames();

            return user;
        }

        #region 隐藏AbpUser的一些字段

        private new string Surname { get; set; }



        [Required(AllowEmptyStrings = true)]
        public override string EmailAddress { get; set; }

        #endregion


        #region 给User增加属性

        /// <summary>
        /// 拼音码
        /// </summary>
        [StringLength(64)]
        public string PinyinCode { get; set; }

        /// <summary>
        /// 账户类型
        /// </summary>
        public AccountTypes AccountType { get; set; }

        public RegisterTypes RegisterType { get; set; }

        [StringLength(18)]
        public string IdentityCard { get; set; }

        /// <summary>
        /// 可用余额
        /// </summary>
        public decimal AvailableBalance { get; set; }

        /// <summary>
        /// 可添加字节点的个数
        /// </summary>
        public int CanAddChildCount { get; set; }

        /// <summary>
        /// 推荐人Id
        /// </summary>
        public long RefereeId { get; set; }

        /// <summary>
        /// 推荐点位Id
        /// </summary>
        public int CreateNetPointId { get; set; }

        /// <summary>
        /// 联系地址
        /// </summary>
        [StringLength(256)]
        public string Address { get; set; }

        /// <summary>
        /// 开户行
        /// </summary>
        [StringLength(32)]
        public string Bank { get; set; }

        /// <summary>
        /// 银行卡号
        /// </summary>
        [StringLength(32)]
        public string BankCardNumber { get; set; }

        #endregion
    }
    public enum RegisterTypes : int
    {
        平台开户 = 0,
        推荐注册 = 1
    }


    public enum AccountTypes : int
    {
        后台账户 = 0,
        会员账户 = 1
    }
    
}
